/*

 Copyright (c) 2008-2009 Fabrizio Pistonesi

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

 */
#ifndef CURSOR_H
#define CURSOR_H

#include<irrlicht.h>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#include"cursor_icon.h"


class Cursor //: public IEventReceiver
{
    public:
        IrrlichtDevice   *Device;                //!< EternitY3D::Device is required.

        IGUIImage        *ScreenCursor;          //!< cursor GUI object.
        ITexture         *Icon;                  //!< texture of the mouse cursor icon.
        position2d<s32>   Hot;                   //!< the cursor center coords.

        dimension2d<s32>  Size;                  //!< size of the mouse icon texture.
        position2d<s32>   MouseLoc;              //!< mouse cursor position (pixel).
        vector3d<f32>     MouseHV;               //!< mouse azimuth-elevation vector.
        position2d<s32>   ClickLoc;              //!< mouse cursor click location.
        bool              Moveable;

        int MouseButton;                         //!< which button has generated the event L=0/R=1/M=2
        int MouseEvent;                          //!< 0 idle, 1 mouse down, 2 mouseup
        u32 LastMouseMove;                       //!< ms past from the last time the mouse was moved.

        u32 EndTime;

        Cursor(IrrlichtDevice *device);
        virtual ~Cursor();
        virtual bool OnEvent(const SEvent& event);
        void setCursor(ECURSOR_ICON icon);                                                         //!< set the type of the cursor ECURSOR_TYPE
        void setCursor(s32 icon);
        void loadCursor(const c8 *filename, position2d<s32> hotPoint = position2d<s32>(0,0));      //!< load a custom cursor from a file \param filename path to the cursor image. \param hotX x coord of the center. \param y coord of the center.
        void draw();                                                                               //!< draw to alpha 50% if the mouse is not moved for 2 seconds
    protected:
    private:
        ICameraSceneNode *MouseCam;
};

#endif // CURSOR_H
